﻿using System;

using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using Silvermoon.OpenGL.Native;

namespace Silvermoon.OpenGL
{
    public class Surface : IDisposable
    {
        #region ctor/dtor

        public Surface(Device device, Bitmap bitmap)
            : base()
        {
            this.Device = device;
            CreateFromBitmap(bitmap);
        }

        public Surface(Device device, int width, int height, PixelFormat format)
            : base()
        {
            this.Device = Device;
            using (Bitmap bm = new Bitmap(width, height, format))
            {
                CreateFromBitmap(bm);
            }
        }

        internal Surface(Device device, IntPtr surface)
            : base()
        {
            this.Device = device;
            this.SurfacePtr = surface;
        }

        public void Dispose()
        {
            if (!egl.DestroySurface(Device.Display, SurfacePtr))
                throw new Exception("Error while destroying surface.");
        }

        #endregion
        #region Properties

        public int Width { get; internal set; }
        public int Height { get; internal set; }


        internal protected IntPtr SurfacePtr { get; private set; }
        public Device Device { get; private set; }

        #endregion
        #region Methods

        void CreateFromBitmap(Bitmap bitmap)
        {
            throw new NotImplementedException();
        }
        #endregion

    }
}
